// ErrorBoundary.js

import React from "react";

class ErrorBoundary extends React.Component {
    constructor(props) {
        super(props);
        this.state = { hasError: false };
    }

    componentDidCatch(error, info) {
        this.setState({ hasError: true });
        console.log(error, info);
    }

    render() {
        if (this.hasError) {
            return <h1>Oops, something went wrong.</h1>;
        }
        return this.props.children;
    }
}

export default ErrorBoundary;
